package com.example.bus.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.auth.domain.User;
import com.example.feign.auth.UserFeignService;
import com.example.util.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private UserFeignService userFeignService;

    @GetMapping("/v1")
    public JSONObject testV1(){
        return Results.success("成功");
    }

    @GetMapping("/v2")
    public JSONObject testV2(@RequestParam("userName")String userName){
        User user=userFeignService.getUserByUserName(userName);
        return Results.success(user);
    }


}
